

const { addSalesmans, getSalesmans, deleteSalesmans, updateSalesmans } = require('../dao/salesmansDao')

module.exports.getSalesmans = async params => {
    const data = await getSalesmans(params);
    return {
        message: '学生数据获取成功',
        status: 1,
        data
    }

}

module.exports.addSalesmans = async params => {
    const data = await addSalesmans(params);
    if (data._id) {
        return {
            message: '新增学生成功',
            status: 1,
            data
        }
    }
    return {
        massage: '新增学生失败',
        status: 0,
    }
}

module.exports.deleteSalesmans = async params => {
    const data = await deleteSalesmans(params);
    if (data.nModified > 0 || data.deletedCount > 0) {
        return {
            message: '删除成功',
            status: 1,
            data,
        }
    }
    return {
        message: '删除失败',
        status: 0
    }
}

module.exports.updateSalesmans = async params => {
    const data = await updateSalesmans(params);
    if (data.nModified > 0) {
        return {
            message: '学生修改成功',
            status: 1
        }
    }
    return {
        message: '学生修改失败',
        status: 0,
        data
    }
}